package lovely.gwt.jsonrpc.test.client;


import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;


public class JsonModel extends BaseJsonModel {

	public String kind;

	public static JsonModel fromJson(JSONValue input) {
		JSONObject jsonObject = input.isObject();
		JsonModel instance = new JsonModel();
		instance.key = jsonObject.get("key").isString().stringValue();
		instance.kind = jsonObject.get("kind").isString().stringValue();
		return instance;
	}

	@Override
	public JSONValue toJson() {
        final JSONObject json = new JSONObject();
        json.put("key", new JSONString(key));
        json.put("kind", new JSONString(kind));
        return json;
	}

	/* for test purpose only
	 * 
	 */
	public JsonModel() {
	}

	public JsonModel(String key, String kind) {
		this.key = key;
		this.kind = kind;
	}

	public String toString() {
		return "kind: " + kind + ", key: " + key;
	}
	
}
